package com.qiwenshare.file.constant;

public enum OperationTypeEnum {
    UPLOAD_FILE(1, "上传文件"),
    ADD_FOLD(2, "新建文件夹"),
    MODIFY_FILE_NAME(3, "文件重命名"),
    MODIFY_FILE(4, "修改文件"),
    DELETE_FILE(5, "删除文件"),
    DELETE_FOLD(6, "删除文件夹"),
    DOWNLOAD_FILE(7, "下载文件")
    ;


    private int type;
    private String desc;
    OperationTypeEnum(int type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public static OperationTypeEnum getEnum(int type) {
        for (OperationTypeEnum ele : OperationTypeEnum.values()) {
            if (ele.getType() == type) {
                return ele;
            }
        }
        return null;
    }

    public static OperationTypeEnum getEnum(int type, int isDir) {
        for (OperationTypeEnum ele : OperationTypeEnum.values()) {
            if (ele.getType() == type) {
                if (type == 5 || type == 6) {
                    if (isDir == 1) {
                        return DELETE_FOLD;
                    }else {
                        return DELETE_FILE;
                    }
                }else {
                    return ele;
                }
            }
        }
        return null;
    }

    public int getType() {
        return type;
    }

    public String getDesc() {
        return desc;
    }
}
